home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
contacts
/
Contact.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
7KB
|
197 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import sys
import traceback
from util import isiterable, callsback
from common.actions import action, ObservableActionMeta
from common import profile
from BuddyListElement import BuddyListElement
from logging import getLogger
log = getLogger('Contact')
objget = object.__getattribute__
CONTACT_ATTRS = set([
'id',
'buddy',
'remove',
'watched',
'__repr__',
'rename_gui',
'rename',
'edit_alerts',
'alias',
'get_group',
'move_to_group__getattr__',
'__hash__',
'__cmp__',
'sort'])
class Contact(object):
watched = 'online '.split()
__metaclass__ = ObservableActionMeta
def __init__(self, buddy, id):
self.buddy = buddy
self.id = id
self._metacontact = None
def remove(self):
self.protocol.remove_buddy(self.id)
def _compatible_accounts(self):
is_compatible = is_compatible
import common.protocolmeta
result = []
for account in profile.connected_accounts:
if is_compatible(account.protocol, self.buddy.service):
result.append(account)
continue
return result
def _all_buddies(self):
result = []
for account in self._compatible_accounts():
if account.connection:
buddy = account.connection.get_buddy(self.buddy.name)
if buddy is not None:
result.append(buddy)
buddy is not None
return result
def _is_blocked(self):
return all((lambda .0: for buddy in .0:
buddy.blocked)(self._all_buddies()))
blocked = property(_is_blocked)
def _block_pred(self, block = True, **k):
return None if bool(block) ^ self._is_blocked() else None
def _unblock_pred(self, *a, **k):
return None if self._is_blocked() else None
def block(self, block = True, **k):
for buddy in self._all_buddies():
if bool(block) ^ bool(buddy.blocked):
buddy.block(block, **k)
continue
block = action(_block_pred)(block)
def unblock(self, *a, **k):
self.block(False, *a, **k)
unblock = action(_unblock_pred)(unblock)
def rename_gui(self):
GetTextFromUser = GetTextFromUser
import gui.toolbox
localalias = self.alias
if localalias is None:
localalias = ''
s = GetTextFromUser(_('Enter an alias for %s:' % self.name), caption = _('Rename %s' % self.name), default_value = localalias)
if s is not None:
if s == '' or s.strip():
None(self.rename if s else None)
return s
rename_gui = action()(rename_gui)
def rename(self, new_alias):
log.info('setting alias for %r to %r', self, new_alias)
profile.set_contact_info(self, 'alias', new_alias)
self.buddy.notify('alias')
def edit_alerts(self):
import gui.pref.prefsdialog as prefsdialog
prefsdialog.show('notifications')
edit_alerts = action()(edit_alerts)
def alias(self):
a = profile.get_contact_info(self, 'alias')
if a:
return a
for attr in ('local_alias', 'remote_alias', 'nice_name'):
try:
a = getattr(self, attr, None)
except Exception:
traceback.print_exc()
continue
if a:
return a
continue
return self.name
alias = property(alias)
def get_group(self):
g = self.protocol.group_for(self)
return g
def move_to_group(self, groupname, index = 0, callback = None):
if not isinstance(groupname, basestring):
raise TypeError, 'groupname must be a string: %r' % groupname
self.protocol.move_buddy_creating_group(self, groupname, self.get_group(), index, callback = callback)
move_to_group = callsback(move_to_group)
def __getattr__(self, attr):
if attr in CONTACT_ATTRS:
return objget(self, attr)
else:
return getattr(objget(self, 'buddy'), attr)
def __repr__(self):
return '<%s %s>' % (self.__class__.__name__, self.buddy)
def __hash__(self):
return hash('%s_%s' % (self.idstr(), self.id))
def __cmp__(self, other):
if self is other:
return 0
else:
return cmp((self.buddy, self.id), (getattr(other, 'buddy', None), getattr(other, 'id', None)))
def sort(self, *a, **k):
pass
class ContactCapabilities:
INFO = 'INFO'
IM = 'IM'
FILES = 'FILES'
PICTURES = 'PICTURES'
SMS = 'SMS'
BLOCKABLE = 'BLOCKABLE'
EMAIL = 'EMAIL'
BOT = 'BOT'
VIDEO = 'VIDEO'